package com.clsfd.ussd;

import java.io.InputStream;
import java.io.OutputStream;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="ussdmessage")
public class UssdMenu  {

	String Action;
	String Heading;
	UssdMenuItem MenuItem[];
	Boolean HasBack;
	Boolean HasHome;
	String Nomatch;
	UssdUserInput Input; 
	
	public UssdMenu() {
	super();
	}
	

	public String getAction() {
		return Action;
	}
 
	@XmlAttribute(name="action")
	public void setAction(String Action) {
		this.Action = Action;
	}
	public String getHeading() {
		return Heading;
	}
 
	@XmlElement(name="heading")
	public void setHeading(String Heading) {
		this.Heading = Heading;
	}
	
	public UssdMenuItem[] getMenuItem() {
		return MenuItem;
	}
 
	@XmlElement(name="menuitem")
	public void setMenuItem(UssdMenuItem []items) {
		this.MenuItem = items;
	}
	


	public Boolean getHasBack() {
		return HasBack;
	}

	@XmlElement(name="hasback")
	public void setHasBack(Boolean hasBack) {
		HasBack = hasBack;
	}

	public Boolean getHasHome() {
		return HasHome;
	}

	@XmlElement(name="hashome")
	public void setHasHome(Boolean hasHome) {
		HasHome = hasHome;
	}
 
	public static UssdMenu decode(InputStream instream) throws JAXBException{
		JAXBContext jc = JAXBContext.newInstance (UssdMenu.class);
        Unmarshaller u = jc.createUnmarshaller ();
        return  (UssdMenu) u.unmarshal ( instream );
	}


	public String getNomatch() {
		return Nomatch;
	}

	@XmlElement(name="nomatch")
	public void setNomatch(String nomatch) {
		Nomatch = nomatch;
	}


	public UssdUserInput getInput() {
		return Input;
	}

	@XmlElement(name="input")
	public void setInput(UssdUserInput input) {
		Input = input;
	}
	
	public void encode(OutputStream os) throws JAXBException{
		JAXBContext jaxbContext = JAXBContext.newInstance(UssdMenu.class);
		Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		jaxbMarshaller.marshal(this, os);
	}
}